import fs from "fs-extra";
import { Nullable } from "../typings/index.js";

export class Record {
    private static _Ins: Record;
    public static get Instance(): Record {
        if (Record._Ins == null) {
            Record._Ins = new Record();
        }
        return this._Ins;
    }

    private file: Nullable<string> = null;

    public async setRecordFile(file: string): Promise<void> {
        this.file = file;
        await fs.ensureFile(file);
    }

    public async recordGUID(guid: string, file: string): Promise<void> {
        if (!this.file) return;
        await fs.appendFile(this.file, guid + '    ' + file + '\n', 'utf-8');
    }
}